//封装文件读取方法
const fs = require("fs");
const getFileData = (path) => {
    return new Promise((resolve, reject) => {
        fs.readFile(path, (err, data) => {
            if (err) {
                console.log("文件读入失败");
                reject(err);
            }
            resolve(data.toString());
        })
    })
}
const setFileData = (path, data) => {
    return new Promise((resolve, reject) => {
        fs.writeFile(path, data, (err) => {
            if (err) {
                console.log("文件写入失败");
                reject(false);
            }
            resolve(true);
        })
    })
}
//暴露
module.exports = {
    getFileData,
    setFileData
}